package com.slz3.business.module.memberManagement.memRecord.domain;

import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.util.UUIDUtils;
import com.slz3.business.frame.util.VE;

import java.time.LocalDateTime;

public class MemRecordFactory {

    /**
     * 初始化基础属性值
     */
    public static MemRecord initBaseFields(MemRecord memRecord) {
        if (memRecord.getUuid() == null) {
            memRecord.setUuid(UUIDUtils.generateUUID());
            memRecord.setCreateTime(LocalDateTime.now());
            if (VE.isEmpty(memRecord.getSerAudit())) {
                memRecord.setSerAudit(AuditFlag.WAIT_SUBMIT);
            }
            if (VE.isEmpty(memRecord.getSerUsing())) {
                memRecord.setSerUsing(UsingFlag.ENABLE);
            }
        } else {
            memRecord.setLastModifyTime(LocalDateTime.now());
        }
        return memRecord;
    }

    /**
     * 初始化基础属性值
     */
    public static MemRecord initBaseFields() {
        return initBaseFields(newTemStyle());
    }

    public static MemRecord newTemStyle() {
        return new MemRecord();
    }

}
